<?php 
$data['page_selected'] = 'management';
$this->load->view('constants/header', $data);?>

<?php if($msg != '_'){ ?>
		<script type="text/javascript">
			alert('<?php echo $msg; ?>');
		</script>
<?php } ?>

<div id="site_content">
	<?php $this->load->view('constants/sidebar'); ?> 
    <div id="content">
        <!-- insert the page content here -->
        <?php $this->load->view('management/menu'); ?>
        <br /><br /><br /><br />
  		<h3 align="center">Empleados de la Fundaci&oacute;n</h3>
        <a href="<?php echo base_url(); ?>management/new_employee" title="Agregar empleado">
        	<img src="<?php echo base_url().IMG; ?>user_add.png" width="100" height="100"/>
        </a>
        <table width="100%" align="center">
        	<thead>
                <th align="center">
                	ID 
                </th>
                <th align="center">
                	C&eacute;dula
                </th>
                <th align="center">
                	Nombre
                </th>
                <th align="center">
                	Cargo
                </th>
                <th align="center">
                	Jefe
                </th>
                <th align="center">
                	Condici&oacute;n
                </th>
                <th align="center" colspan="2"></th>
                <?php foreach($employees as $e){ ?>
                	<tr>
                    	<td align="center">
                        	<?php echo $e['id_empleado']; ?>
                        </td>
                    	<td align="center">
                        	<?php echo $e['ci_empleado']; ?>
                        </td>
                        <td align="center">
                        	<a href="javascript:void(0)" onclick="get_employee_detail('<?php echo $e['id_empleado']; ?>')">
								<?php echo $e['nombre'].' '.$e['apellido']; ?>
                            </a>
                        </td>
                        <td align="center">
                        	<?php echo $e['descripcion_cargo']; ?>
                        </td>
                        <td align="center">
                        	<?php 
							if($e['ID_JEFE_INMEDIATO']){
								echo $e['ID_JEFE_INMEDIATO'];
							}
							else{
								echo 'N/A';
							}
							?>
                        </td>
                        <td align="center">
                        	<?php echo $e['condicion']; ?>
                        </td>
                        <td align="center">
                        	<a href="<?php echo base_url(); ?>management/edit_employee/<?php echo $e['id_empleado']; ?>">
								<img src="<?php echo base_url().IMG ?>pencil_icon.png" width="16px" height="16px"/>
                            </a>
                        </td>
                        <td align="center">
                        	<?php 
							$img = 'Eraser-icon';
							$title = 'Inactivar';
							if($e['condicion'] != 'activo'){ 
								$img = 'checked'; 
								$title = 'Activar';
							} ?>
							<form action="<?php echo base_url(); ?>management/update_employee_status" method="post" 
															onsubmit="return check('<?php echo $e['nombre'].' '.$e['apellido']; ?>', '<?php echo $title; ?>');">
								<input type="hidden" name="id_user" id="id_user" value="<?php echo $e['id_empleado']; ?>"/>
								<input type="image" title="<?php echo $title ?> empleado" align="Submit" src="<?php echo base_url().IMG.$img ?>.png" width="16px" height="16px"/>
							</form>
                        </td>
                    </tr>
                    <tr>
                    	<td colspan="8">
                        	<div style="display: none" id="employee_detail_div<?php echo $e['id_empleado']; ?>">
                            </div>
                        </td>
                    </tr>
				<?php } ?>
            </thead>
        </table>
    </div>
</div>
<?php $this->load->view('constants/footer'); ?>
<script type="text/javascript">
	function check(name, action){
		if(confirm("Esta seguro de querer "+action+" al empleado: "+name)){
			return true;
		}
		else{
			return false;
		}
	}
</script>